package com.ctshk.rpc.goods.mapper.provider;

import org.apache.ibatis.jdbc.SQL;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ctshk.rpc.goods.dto.ShoppingShopStoreDetailedDTO;
import com.ctshk.rpc.goods.req.ShoppingShopStorePageReq;

/**
 * 商城管理-分页列表查询
 * @author 姜斌文
 * @since 2021-04-06
 */
public class ShoppingShopStoreDetailedProvider {

    public String findShoppingShopStoreDetailedByCondition(IPage<ShoppingShopStoreDetailedDTO> page,ShoppingShopStorePageReq pageReq) {
    	String sql = new SQL() {{
                SELECT("t.id,t.store_invitation_code,t.head_portrait_url,t.store_name,t.staff_id, t.staff_name, t.shop_id, t.shop_name,t.shop_type,t.status,t.gmt_create");
                FROM("t_shopping_shop_store t");
                // store_type：1-总店，2-分店；staff_type:1-管理员，2-成员
                if (null != pageReq.getId()) {
                    WHERE("t.store_id = #{pageReq.storeId} OR t.id = #{pageReq.id}");
                }
                ORDER_BY("t.staff_type ASC");
            }}.toString();
            return sql;
    }
}
